<?php



class TestWakIniFile extends UnitTestCase {

    function setUp() {
        $this->_deleteFile(dirname(__FILE__).'/test.ini');
    }

    function tearDown() {
        // $this->_deleteFile(dirname(__FILE__).'/test.ini');
    }

    function testCycle() {
        // sample data
        $data=array(
            'a_key'=>'a value'
            ,'section'=>array(
                'twelve'=>12
                ,'thirty-six'=>36
                ,'latin'=>'Lorem Ipsum Dolor Sit Amet')
            );
        $path=dirname(__FILE__).'/test.ini';
        $ini=new WakIniFile($path);
        $this->assertFalse($ini->getData()
            ,"getData() shall return false for non-existing INI files");
        $this->assertTrue($ini->setData($data)
            ,"setData() shall return true");
        $this->assertEqual($ini->getData(),$data
            ,"and save data as INI file");
    }

    function _deleteFile($file) {
        if (file_exists($file) and !unlink($file)) {
            $this->fail("cant' start tests, file '.$file.' should not exist before tests %s'");
            return false;
        }
        return true;
    }
}